//
// CMeshMRM.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.IStream;

public class CMeshMRM extends CMeshBase {
  private long swigCPtr;

  public CMeshMRM(long cPtr, boolean cMemoryOwn) {
    super(nel3dJNI.CMeshMRM_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(CMeshMRM obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CMeshMRM(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public CMeshMRM() {
    this(nel3dJNI.new_CMeshMRM(), true);
  }

  public void build(SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild mBase, SWIGTYPE_p_NL3D__CMesh__CMeshBuild m, SWIGTYPE_p_std__vectorT_NL3D__CMeshBuild_p_t listBS, CMRMParameters params) {
    nel3dJNI.CMeshMRM_build__SWIG_0(swigCPtr, this, SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild.getCPtr(mBase), SWIGTYPE_p_NL3D__CMesh__CMeshBuild.getCPtr(m), SWIGTYPE_p_std__vectorT_NL3D__CMeshBuild_p_t.getCPtr(listBS), CMRMParameters.getCPtr(params), params);
  }

  public void build(SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild mBase, SWIGTYPE_p_NL3D__CMesh__CMeshBuild m, SWIGTYPE_p_std__vectorT_NL3D__CMeshBuild_p_t listBS) {
    nel3dJNI.CMeshMRM_build__SWIG_1(swigCPtr, this, SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild.getCPtr(mBase), SWIGTYPE_p_NL3D__CMesh__CMeshBuild.getCPtr(m), SWIGTYPE_p_std__vectorT_NL3D__CMeshBuild_p_t.getCPtr(listBS));
  }

  public void build(SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild m, CMeshMRMGeom mgeom) {
    nel3dJNI.CMeshMRM_build__SWIG_2(swigCPtr, this, SWIGTYPE_p_NL3D__CMeshBase__CMeshBaseBuild.getCPtr(m), CMeshMRMGeom.getCPtr(mgeom), mgeom);
  }

  public void optimizeMaterialUsage(SWIGTYPE_p_std__vectorT_int_t remap) {
    nel3dJNI.CMeshMRM_optimizeMaterialUsage(swigCPtr, this, SWIGTYPE_p_std__vectorT_int_t.getCPtr(remap));
  }

  public void computeBonesId(CSkeletonModel skeleton) {
    nel3dJNI.CMeshMRM_computeBonesId(swigCPtr, this, CSkeletonModel.getCPtr(skeleton), skeleton);
  }

  public void updateSkeletonUsage(CSkeletonModel sm, boolean increment) {
    nel3dJNI.CMeshMRM_updateSkeletonUsage(swigCPtr, this, CSkeletonModel.getCPtr(sm), sm, increment);
  }

  public void changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest) {
    nel3dJNI.CMeshMRM_changeMRMDistanceSetup(swigCPtr, this, distanceFinest, distanceMiddle, distanceCoarsest);
  }

  public CTransformShape createInstance(CScene scene) {
    long cPtr = nel3dJNI.CMeshMRM_createInstance(swigCPtr, this, CScene.getCPtr(scene), scene);
    return (cPtr == 0) ? null : new CTransformShape(cPtr, false);
  }

  public boolean clip(SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t pyramid, SWIGTYPE_p_NLMISC__CMatrix worldMatrix) {
    return nel3dJNI.CMeshMRM_clip(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CPlane_t.getCPtr(pyramid), SWIGTYPE_p_NLMISC__CMatrix.getCPtr(worldMatrix));
  }

  public void render(IDriver drv, CTransformShape trans, boolean passOpaque) {
    nel3dJNI.CMeshMRM_render(swigCPtr, this, IDriver.getCPtr(drv), drv, CTransformShape.getCPtr(trans), trans, passOpaque);
  }

  public float getNumTriangles(float distance) {
    return nel3dJNI.CMeshMRM_getNumTriangles(swigCPtr, this, distance);
  }

  public void serial(IStream f) {
    nel3dJNI.CMeshMRM_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public void getAABBox(SWIGTYPE_p_NLMISC__CAABBox bbox) {
    nel3dJNI.CMeshMRM_getAABBox(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox));
  }

  public void profileSceneRender(CRenderTrav rdrTrav, CTransformShape trans, boolean opaquePass) {
    nel3dJNI.CMeshMRM_profileSceneRender(swigCPtr, this, CRenderTrav.getCPtr(rdrTrav), rdrTrav, CTransformShape.getCPtr(trans), trans, opaquePass);
  }

  public void buildSystemGeometry() {
    nel3dJNI.CMeshMRM_buildSystemGeometry(swigCPtr, this);
  }

  public SWIGTYPE_p_NLMISC__CAABBoxExt getBoundingBox() {
    return new SWIGTYPE_p_NLMISC__CAABBoxExt(nel3dJNI.CMeshMRM_getBoundingBox(swigCPtr, this), false);
  }

  public CVertexBuffer getVertexBuffer() {
    return new CVertexBuffer(nel3dJNI.CMeshMRM_getVertexBuffer(swigCPtr, this), false);
  }

  public long getNbLod() {
    return nel3dJNI.CMeshMRM_getNbLod(swigCPtr, this);
  }

  public long getNbRdrPass(long lodId) {
    return nel3dJNI.CMeshMRM_getNbRdrPass(swigCPtr, this, lodId);
  }

  public CIndexBuffer getRdrPassPrimitiveBlock(long lodId, long renderingPassIndex) {
    return new CIndexBuffer(nel3dJNI.CMeshMRM_getRdrPassPrimitiveBlock(swigCPtr, this, lodId, renderingPassIndex), false);
  }

  public long getRdrPassMaterial(long lodId, long renderingPassIndex) {
    return nel3dJNI.CMeshMRM_getRdrPassMaterial(swigCPtr, this, lodId, renderingPassIndex);
  }

  public CMeshMRMGeom getMeshGeom() {
    return new CMeshMRMGeom(nel3dJNI.CMeshMRM_getMeshGeom(swigCPtr, this), false);
  }

  public IMeshGeom supportMeshBlockRendering(CTransformShape trans, SWIGTYPE_p_float polygonCount) {
    long cPtr = nel3dJNI.CMeshMRM_supportMeshBlockRendering(swigCPtr, this, CTransformShape.getCPtr(trans), trans, SWIGTYPE_p_float.getCPtr(polygonCount));
    return (cPtr == 0) ? null : new IMeshGeom(cPtr, false);
  }

}
